package wahadlo.nowe.gui;

import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.ButtonGroup;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import wahadlo.nowe.model.Model;
import wahadlo.nowe.model.ModelSupplier;
import wahadlo.nowe.model.StandardModel;

public class TypeComponent extends JPanel implements ModelSupplier {

	private static final long serialVersionUID = 1L;

	private JCheckBox inclination_t = new JCheckBox("Wychylenie");
	private JCheckBox speed_t = new JCheckBox("Prędkość");
	// private JCheckBox cbEk_t = new JCheckBox("Energia kin.");
	// private JCheckBox cbEp_t = new JCheckBox("Energia pot.");
	// private JCheckBox cbE = new JCheckBox("Energia cał.");
	// private JCheckBox cbPhase = new JCheckBox("Przestrzeń fazowa");

	private ButtonGroup checkboxGroup = new ButtonGroup();

	public TypeComponent() {
		setMinimumSize(new Dimension(200, 200));
		setLayout(new GridLayout(1, 6));
		// domyśnie wykres wychylenia
		init();
		
		// addElement(cbEk_t);
		// addElement(cbEp_t);
		// addElement(cbE);
		// addElement(cbPhase);

	}

	private void init() {
		inclination_t.setSelected(true);
		addElement(inclination_t);
		addElement(speed_t);
	}

	private void addElement(JCheckBox element) {
		checkboxGroup.add(element);
		element.setVerticalTextPosition(SwingConstants.BOTTOM);
		this.add(element);
	}

	public Model getModel() {
		StandardModel model = new StandardModel();
		if (inclination_t.isSelected())
			model.add("chartType", "inclination_t");
		else if (speed_t.isSelected())
			model.add("chartType", "speed_t");
		else
			model.add("chartType", null);

		return model;
	}
}
